#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>


int main(int argc, char* argv[]){
  int fd, ret;
  int key_val;

  if(argc != 2){
    printf("input number error!\n");
    return -1;
  }

  fd = open(argv[1], O_RDONLY);
  if(fd < 0){
    printf("open file error\n");
    return -1;
  }
  printf("fd: %d \n", fd);

  while(1){
    read(fd, &key_val, sizeof(int));
    printf("keyApp key_value: %d\n", key_val);
    if(key_val == 0){
      printf("key press\n");
    }else if(key_val == 1){
      printf("key release\n");
    }
  }
  close(fd);
  return 0;
}